package model

import "kpt-dtm/model/yyn"

type Spread struct {
	Id        int64 `json:"id"`
	PastureId int64 `json:"pasture_id"`
	SpreadId  int64 `json:"spread_id"`
	CreatedAt int64 `json:"created_at"`
	UpdatedAt int64 `json:"updated_at"`
}

func (s *Spread) TableName() string {
	return "d_spread"
}

func NewSpread(pastureId, spreadId int64) *Spread {
	return &Spread{
		PastureId: pastureId,
		SpreadId:  spreadId,
	}
}

func NewSpreadList(pastureId int64, res []*yyn.UploadDiliverData) []*Spread {
	var list = make([]*Spread, 0)
	for _, v := range res {
		list = append(list, NewSpread(pastureId, v.ElabLoadId))
	}
	return list
}
